<template>
    <div class="hngkContent">
        <BigTitle/>
        <component :is="$store.state.hngkComponent"></component>
    </div>
</template>

<script>
import Gk from './Gk'
import Fx from './Fx'
import BigTitle from './hngkParts/BigTitle'
import {defineComponent,getCurrentInstance,onMounted,ref,computed,onUnmounted,onBeforeUnmount} from 'vue'
import axios from 'axios'
import { useStore } from 'vuex'
export default defineComponent({
    components:{
        Gk,
        Fx,
        BigTitle
    },
    setup(){
        const store = useStore()
        let currentComponent = computed(()=>{
            return store.state.hngkComponent
        })
        //1, 无法传参，请求时间略长
        // axios.post(`http://172.25.110.34:81/foundation/union/subject/shcdlxxjSxjxzqhcxfw/list`,{}).then(res=>{
        //     console.log(res.data)
        //     //let arr = res.data.data[0].result.result[0].geometry;
        //     let arr = res.data.data[0].result.result[9].geometry;
        //     console.log(arr);
        //     //一，针对多个POLYGON
        //     //首位转译成 [[ ]] , ((转译成[ ,  ))转译成] ,  去掉经纬度之间的空格;
        //     //将原来的 MULTIPOLYGON((( )),(()),(( ))),转译成二维数组[[],[],[]];
        //     if(arr.indexOf("MULTI")>-1){
        //         let arr1 = arr.replace("MULTIPOLYGON(((", "[[").replace(")))","]]").replace(/\(+/g, "[").replace(/\)+/g, "]").replace(/\s+/g, ",");
        //         let arr2 = eval( "(" + arr1 + ")" )
        //         console.log(arr2)
        //         arr2.forEach((item,index) => {
        //             layerManager.addPloygonLine("woshinidaye"+index,item)
        //         });
        //     }else{
        //         //二，针对POLYGON 首位替换，去掉
        //         let arr1 = arr.replace("POLYGON((", "[").replace("))","]").replace(/\s+/g, ",");
        //         let arr2 = eval( "(" + arr1 + ")" )
        //         console.log(arr2)
        //         layerManager.addPloygonLine("woshinidaye",arr2)
        //     }
        // })
        // axios.post('http://172.25.110.34:81/foundation/union/subject/shcdlxxjIljrhyhxqxxWmtscapabilitiesjk/list',{}).then(res=>{
        //     console.log(res)
        // })
        //水库
        // axios.post('http://172.25.110.34:81/foundation/cehuiju/shuiku',{}).then(res=>{
        //     console.log(res)
        // })
        // async function getData(){
        //     const a = await axios.get('./data/data.json');
        //     console.log(a)
        //     const b = await axios.get('./data/data.json');
        //     console.log("b" + a)
            
        // }
        // getData()
        // console.log("XCV")
        //交通情况
        // function getJTQK(){
        //    return axios.get('http://172.25.110.34:81/foundation/cehuiju/jtqk')
        // }
        // let a = 0;
        // await getJTQK().then(res=>{
        //     a = res;
        // });
        // console.log(a)
        
        
        // axios.get('http://172.25.110.34:81/foundation/cehuiju/jtqk').then(res=>{
        //     console.log(res)
        // })
        //地名地址，有村的信息
        // axios.get('http://172.25.110.34:81/foundation/cehuiju/dmdz?page_num=0&page_size=10000').then(res=>{
        //     console.log(res)
        // })
        //自然地理
        // axios.get('http://172.25.110.34:81/foundation/cehuiju/zrdl').then(res=>{
        //     console.log(res)
        // })
        //行政区划（市县及市县下辖区）
        // axios.get('http://172.25.110.34:81/foundation/cehuiju/xzqh?sxjname=&qjname=').then(res=>{
        //     console.log(res)
        // })
        //经纬度反查
//         axios.post('http://172.25.110.34:81/foundation/cehuiju/jwdfcxzqh',{"lon":"109.94278203000005",
// "lat":"19.992792808000047"}).then(res=>{
//             console.log(res)
//         })
//  this.pointPrimitive = null;
        onMounted(()=>{
            // var p = viewer.pointPrimitives.add({
            // show : true,
            // position : Cesium.Cartesian3.fromDegrees(110.198418, 20.045805,30000),
            // pixelSize : 10.0,
            // color : Cesium.Color.WHITE,
            // outlineColor : Cesium.Color.TRANSPARENT,
            // outlineWidth : 0.0,
            // id : "moni"
            // });
           // 初始化一个点的可渲染集合。
            // this.pointPrimitive = viewer.scene.primitives.add(new Cesium.PointPrimitiveCollection());
            // this.pointPrimitives.add({
            //    pixelSize: 5,
            //    color: Cesium.Color[colorList[Math.round(common.randomNumber(0, 15))]],
            //    outlineColor: outlineColor,
            //    outlineWidth: 0,
            //    position:Cesium.Cartesian3.fromDegrees(110.198418, 20.045805,30000)
            // });
            store.commit("changeHngkComponent","Gk")
            // axios.post(`http://172.25.110.34:81/foundation/cehuiju/shuiku`,{}).then(res=>{
            // })
            // axios.post(`http://172.25.110.34:81/foundation/union/subject/shcdlxxjSxjxzqhcxfw/list`,data).then(res=>{
            //     console.log('res=>',res);
            //     //let arr = res.data.data[0].result.result.map((item)=>{return item.geometry});
            //     let arr = res.data.data[0].result.result[0].geometry;
            //     console.log(arr.substring(15 ,arr.length-2))  
            //     //["海南省", "五指山市", "屯昌县", "澄迈县", "白沙黎族自治县", "昌江黎族自治县", "保亭黎族苗族自治县", "琼中黎族苗族自治县", "儋州市", "东方市"]        
            // })
            // axios.post(`http://172.25.110.34:81/foundation/union/subject/shcdlxxjIljrhyhxqxxWmtscapabilitiesjk/list`,data).then(res=>{
            //     console.log('res=>',res);
            // })
        })
        onUnmounted(()=>{
            layerManager.removeAll();
            store.commit("changeDescShow", false);
            // var p = window.viewer.pointPrimitives.add({
            // show : true,
            // position : Cesium.Cartesian3.fromDegrees(110.198418, 20.045805,30000),
            // pixelSize : 10.0,
            // color : Cesium.Color.WHITE,
            // outlineColor : Cesium.Color.TRANSPARENT,
            // outlineWidth : 0.0,
            // id : undefined
            // });
        })
         onBeforeUnmount(()=>{
             console.log(123)
             layerManager.removeAll();
         })
        return {
            currentComponent,
            onBeforeUnmount
        }
    }
})
</script>

<style lang="stylus" scoped>
   
</style>